{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "88d3ce08",
   "metadata": {},
   "source": [
    "* 2022/09/20/week05\n",
    "* python课堂笔记"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6254948d",
   "metadata": {},
   "source": [
    "# 本周内容\n",
    "> 1.有序的数据结构列表\n",
    "\n",
    "> 2.用户输入\n",
    "\n",
    "> 3.关于格式化文本信息"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2363a1ed",
   "metadata": {},
   "outputs": [],
   "source": [
    "网三_01_name = \"name\"\n",
    "\n",
    "# 思考：如果想一个变量存放一个班同学的名字 该怎么存\n",
    "# 思考1：处理数据会不会比较麻烦"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "d9f7bec4",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Marry,Alex,Jack,周晓明\n"
     ]
    }
   ],
   "source": [
    "网三_name_list = \"Marry,Alex,Jack,周晓明\"\n",
    "print(网三_name_list)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "c8f735f0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Alex'"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网三_name_list[6:10]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "c0e8b4e2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "19"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 思考：我想知道这个名单有多少个人名\n",
    "len(网三_name_list)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "86fbe1b2",
   "metadata": {},
   "source": [
    "## 1.引入列表的概念\n",
    "* Lists might contain items of different types, but usually the items all have the same type.\n",
    "> 注释：我们已经学习了 数值 和 字符 ，list可以放数值和字符，但是通常要么一起放数值，要么一起放字符串\n",
    "> 总结一些通用的有序数据结构的方法：\n",
    ">> 1.取值：通过索引值取出对应内容\n",
    ">> 2.切片：通过索引值区间取出对应的一些内容\n",
    ">> 3. in 可以查看成员对象是否存在\n",
    "\n",
    "> 列表的一些方法"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "98966d1b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1, 2, 3, 4] <class 'list'>\n"
     ]
    }
   ],
   "source": [
    "a = [1,2,3,4]\n",
    "print(a,type(a))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "873d8ba9",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['Marry', 'Alex', 'Jack', '周晓明'] <class 'list'>\n"
     ]
    }
   ],
   "source": [
    "网三_name_list = [\"Marry\",\"Alex\",\"Jack\",\"周晓明\"]\n",
    "print(网三_name_list,type(网三_name_list ))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e05d8eb5",
   "metadata": {},
   "source": [
    "### 1.1 列表的运算法则 \n",
    "* <font color=\"red\">列表的数据本身不做修改"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "c187e096",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Marry'"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 取出网三_name_list  中第一位同学的名字\n",
    "网三_name_list[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "e70bcb16",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "4"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 查看网三_name_list有多少位同学\n",
    "len(网三_name_list)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "512d33d3",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "网三： Marry\n",
      "网三： Alex\n",
      "网三： Jack\n",
      "网三： 周晓明\n"
     ]
    }
   ],
   "source": [
    "for i in 网三_name_list:\n",
    "    print(\"网三：\",i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "4cf64566",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 关于运算法则（in + 切片 取值 len（s）s.count）\n",
    "网三_name_list_转专业 = [\"Xiaoming\",\"Lihua\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "43668790",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Marry', 'Alex', 'Jack', '周晓明', 'Xiaoming', 'Lihua']"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网三_name_list + 网三_name_list_转专业"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "3881f65b",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 思考：一个list 可不可以出现重复项？\n",
    "网一_age_list = [18,19,19,18,20,19]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "7211e102",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[18, 19, 19, 18, 20, 19]"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网一_age_list"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e3e2b7b6",
   "metadata": {},
   "source": [
    "### 2.2 列表的方法 --对列表数据进行操作\n",
    "\n",
    "> 1.增  \n",
    "> 2.删  \n",
    "> 3.改  \n",
    "> 4.查  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "97ac79a5",
   "metadata": {},
   "outputs": [],
   "source": [
    "### append增加元素到末尾"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a390072e",
   "metadata": {},
   "outputs": [],
   "source": [
    "网三_name_list = \"Marry,Alex,Jack,周晓明\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "id": "45843b53",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Marry', 'Alex', 'Jack', '周晓明']"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网三_name_list"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "c8e0539d",
   "metadata": {},
   "outputs": [],
   "source": [
    "网三_name_list.append(\"张志豪\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "id": "66a12479",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Marry', 'Alex', 'Jack', '周晓明', '张志豪']"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网三_name_list"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "id": "19811892",
   "metadata": {},
   "outputs": [],
   "source": [
    "网三_name_list.append(\"张文鑫\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "id": "d0734636",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Marry', 'Alex', 'Jack', '周晓明', '张志豪', '张文鑫']"
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网三_name_list"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "79d77fb7",
   "metadata": {},
   "outputs": [],
   "source": [
    "# insert 增加元素到某个位置"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "id": "8d9517b2",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function insert:\n",
      "\n",
      "insert(index, object, /) method of builtins.list instance\n",
      "    Insert object before index.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(网三_name_list.insert)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "id": "87df6c27",
   "metadata": {},
   "outputs": [],
   "source": [
    "网三_name_list.insert(1,\"李华\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "id": "a3962646",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Marry', '李华', 'Alex', 'Jack', '周晓明', '张志豪', '张文鑫']"
      ]
     },
     "execution_count": 50,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网三_name_list"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5bef6687",
   "metadata": {},
   "outputs": [],
   "source": [
    "# remove "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "id": "ea87188f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function remove:\n",
      "\n",
      "remove(value, /) method of builtins.list instance\n",
      "    Remove first occurrence of value.\n",
      "    \n",
      "    Raises ValueError if the value is not present.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(网三_name_list.remove)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "id": "5682ca20",
   "metadata": {},
   "outputs": [],
   "source": [
    "网三_name_list.remove('Alex')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "id": "6dd48471",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Marry', '李华', 'Jack', '周晓明', '张志豪', '张文鑫']"
      ]
     },
     "execution_count": 53,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网三_name_list"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "id": "97145c4e",
   "metadata": {},
   "outputs": [
    {
     "ename": "ValueError",
     "evalue": "list.remove(x): x not in list",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mValueError\u001b[0m                                Traceback (most recent call last)",
      "Input \u001b[1;32mIn [54]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[43m网三_name_list\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mremove\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mAlex\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m)\u001b[49m\n",
      "\u001b[1;31mValueError\u001b[0m: list.remove(x): x not in list"
     ]
    }
   ],
   "source": [
    "网三_name_list.remove('Alex')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "id": "f3858461",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Marry', '李华', 'Jack', '周晓明', '张志豪', '张文鑫']"
      ]
     },
     "execution_count": 55,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# remove经常和 in 一起使用 ，先检查成员变量是否存在 然后再remove\n",
    "if \"Alex\" in 网三_name_list:\n",
    "    网三_name_list.remove(\"Alex\")\n",
    "网三_name_list"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "50a26e7a",
   "metadata": {},
   "outputs": [],
   "source": [
    "# pop "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "id": "c55cf29c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function pop:\n",
      "\n",
      "pop(index=-1, /) method of builtins.list instance\n",
      "    Remove and return item at index (default last).\n",
      "    \n",
      "    Raises IndexError if list is empty or index is out of range.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(网三_name_list.pop)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "id": "33447d92",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Marry', '李华', 'Jack', '周晓明', '张志豪']"
      ]
     },
     "execution_count": 59,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网三_name_list"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "id": "7fe2f999",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'张文鑫'"
      ]
     },
     "execution_count": 57,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网三_name_list.pop()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "id": "83464510",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Jack'"
      ]
     },
     "execution_count": 60,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网三_name_list.pop(2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "id": "69752263",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function clear:\n",
      "\n",
      "clear() method of builtins.list instance\n",
      "    Remove all items from list.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(网三_name_list.clear)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "id": "df747953",
   "metadata": {},
   "outputs": [],
   "source": [
    "网三_name_list.clear()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "id": "3c53be55",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[]"
      ]
     },
     "execution_count": 65,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网三_name_list"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 75,
   "id": "bee1e184",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 实践请移除19的元素\n",
    "age_list = [18,19,18,19,17,20,20,18,19,16,17,20]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 76,
   "id": "58f66000",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3"
      ]
     },
     "execution_count": 76,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "age_list.count(19)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 81,
   "id": "94a3b7d2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[18, 19, 18, 19, 17, 20, 20, 18, 19, 16, 17, 20]"
      ]
     },
     "execution_count": 81,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "age_list"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 83,
   "id": "2441e4da",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[18, 18, 17, 20, 20, 18, 16, 17, 20]"
      ]
     },
     "execution_count": 83,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 思路1:remove（value）先决条件 知道值出现的次数\n",
    "删除的数量 = age_list.count(19)\n",
    "for i in range(删除的数量):\n",
    "    if 19 in age_list:\n",
    "        age_list.remove(19)\n",
    "    age_list\n",
    "age_list"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 84,
   "id": "0781cad4",
   "metadata": {},
   "outputs": [],
   "source": [
    "age_list = [18,19,18,19,17,20,20,18,19,16,17,20]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 88,
   "id": "82c7b194",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1 19\n",
      "2 19\n",
      "6 19\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "[18, 18, 17, 20, 20, 18, 16, 17, 20]"
      ]
     },
     "execution_count": 88,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 思路2：pop（index），先决条件 知道值出现的位置\n",
    "for i,v in enumerate(age_list):\n",
    "    if v == 19:\n",
    "        print(i,v)\n",
    "        age_list.pop(i)\n",
    "age_list"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "95079e57",
   "metadata": {},
   "source": [
    "# 课后练习\n",
    "# 1.p68 p81\n",
    "# 2.剩下的reverse extend clear copy sort尝试练习\n",
    "# 3.总结列表的方法 用表格的形式写markdown上"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5e352e52",
   "metadata": {},
   "outputs": [],
   "source": [
    "# p68"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "97c5ebcc",
   "metadata": {},
   "outputs": [],
   "source": [
    "phrase = \"Don't panic!\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "600c89bf",
   "metadata": {},
   "outputs": [],
   "source": [
    "plist = list(phrase)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "e952905a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Don't panic!\n",
      "['D', 'o', 'n', \"'\", 't', ' ', 'p', 'a', 'n', 'i', 'c', '!']\n"
     ]
    }
   ],
   "source": [
    "print(phrase)\n",
    "print(plist)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "dc88a60e",
   "metadata": {},
   "outputs": [],
   "source": [
    "for i in range(4):\n",
    "     plist.pop()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "874e1708",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'D'"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "plist.pop(0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "3e59b647",
   "metadata": {},
   "outputs": [],
   "source": [
    "plist.remove(\"'\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "a40e0a62",
   "metadata": {},
   "outputs": [],
   "source": [
    "plist.extend([plist.pop(),plist.pop()])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "a849e30e",
   "metadata": {},
   "outputs": [],
   "source": [
    "plist.insert(2,plist.pop(3))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "37a13b91",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['o', 'n', ' ', 't', 'a', 'p']\n"
     ]
    }
   ],
   "source": [
    "print(plist)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "1b973407",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['o', 'n', ' ', 't', 'a', 'p']\n",
      "on tap\n"
     ]
    }
   ],
   "source": [
    "new_phrase = ''.join(plist)\n",
    "print(plist)\n",
    "print(new_phrase)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e467704b",
   "metadata": {},
   "outputs": [],
   "source": [
    "# p81"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "7c1902b8",
   "metadata": {},
   "outputs": [],
   "source": [
    "phrase = \"Don't panic!\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "id": "bdc8f541",
   "metadata": {},
   "outputs": [],
   "source": [
    "plist = list(phrase)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "id": "fc9300c7",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Don't panic!\n",
      "['D', 'o', 'n', \"'\", 't', ' ', 'p', 'a', 'n', 'i', 'c', '!']\n"
     ]
    }
   ],
   "source": [
    "print(phrase)\n",
    "print(plist)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "id": "7375c2df",
   "metadata": {},
   "outputs": [],
   "source": [
    "new_phrase = ''.join(plist[1:3])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "id": "87a89565",
   "metadata": {},
   "outputs": [],
   "source": [
    "new_phrase = new_phrase + ''.join([plist[5],plist[4],plist[7],plist[6]])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "id": "4664fb34",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['D', 'o', 'n', \"'\", 't', ' ', 'p', 'a', 'n', 'i', 'c', '!']\n",
      "on tap\n"
     ]
    }
   ],
   "source": [
    "print(plist)\n",
    "print(new_phrase)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "id": "00c63537",
   "metadata": {},
   "outputs": [],
   "source": [
    "网三_name_list = \"Marry,Alex,Jack,周晓明\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "id": "e31d3158",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Marry,Alex,Jack,周晓明'"
      ]
     },
     "execution_count": 65,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网三_name_list"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "id": "567a5375",
   "metadata": {},
   "outputs": [
    {
     "ename": "AttributeError",
     "evalue": "'str' object has no attribute 'append'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mAttributeError\u001b[0m                            Traceback (most recent call last)",
      "Input \u001b[1;32mIn [68]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[43m网三_name_list\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mappend\u001b[49m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m张文鑫\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n",
      "\u001b[1;31mAttributeError\u001b[0m: 'str' object has no attribute 'append'"
     ]
    }
   ],
   "source": [
    "网三_name_list.append(\"张文鑫\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b75f1fc6",
   "metadata": {},
   "source": [
    "# 列表的方法\n",
    "\n",
    "| 1.取值：通过索引值取出对应内容           |\n",
    "| :--------------------------------------- |\n",
    "| 2.切片：通过索引值区间取出对应的一些内容 |\n",
    "| 3.in 可以查看成员对象是否存在            |\n",
    "| 4.开始、结束、步长值：star、stop、step   |\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "bf9bc952",
   "metadata": {},
   "source": [
    "| <center>列表也是一个变量，构建列表需要用”[]“，里面的数据之间用”,“进行分隔。</center> |\n",
    "| ------------------------------------------------------------ |\n",
    "| a.切片      b.增、减、删、改、查：append 增加，增加元素到末尾；insert 增加元素到每个位置；extend 扩展 新的内容是追加到原列表最后一个元素的后面；remove 删除 删除一个指定元素；pop 删除；clear 清除 清除列表里面所有元素；sort 对列表进行正向排序；reverse 对列表进行逆向排序；index(x,star,end)  顾名思义x表示在列表查找的元素，star表示开始查找的下标索引值的位置，end表示结束查找的下标索引值的位置；copy 拷贝 拷贝一个列表，同时也可以使用切片，对拷贝的内容进行限制。 |"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5eb5649a",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
